<template>
  <div class="kg-head-he"></div>
  <header class="kg-head reg-top">
    <div class="dqxz" @click="back"><i class="micon">&#xe61e;</i></div>
    <div class="search_box show-cansu">
      考试报名
    </div>
  </header>
  
    <div>
    <a-spin :spinning="isLoading">
      <a-form
      :form="formState"
      @finish="onFinish"
      @finishFailed="onFinishFailed"
      >
        <div class="kg-center">
        <!---->
     
        <!---->   
          <div class="kg-ksbox mb25">
            <div class="title">
            <div class="title_a">考生信息</div>
            </div>
            
            <div class="kg-ksxqbox">
              <div class="kg-ksxq-list">
                <div class="kg-ksxq-lista">考生姓名</div>
                <div class="kg-ksxq-listb">
                  <a-form-item
                    name="username"
                    :rules="[{ required: true, message: 'Please input your nick_name!' }]"
                  >
                    <a-input class="input-a" v-model:value="formState.nick_name" />
                  </a-form-item>
                </div>
              </div>
              <a-form-item
                name="password"
                :rules="[{ required: true, message: '请输入密码!' }]"
              >
                <a-input-password v-model:value="formState.password"  placeholder="请输入密码">
                  <template #prefix>
                    <LockOutlined class="site-form-item-icon" />
                  </template>
                </a-input-password>
              </a-form-item>
              <div class="kg-ksxq-list">
                <div class="kg-ksxq-lista">所学专业</div>
                <div class="kg-ksxq-listb">
                  <a-form-item
                    name="specialty"
                    :rules="[{ required: true, message: 'Please input your 所学专业!' }]"
                  >
                    <a-input class="input-a" v-model:value="formState.specialty" >
                    </a-input>
                  </a-form-item>
                </div>
              </div>
              <div class="kg-ksxq-list">
                <div class="kg-ksxq-lista">所属地</div>
                <div class="kg-ksxq-listb"><input class="input-a" type="text" placeholder="请输入" value=""/></div>
              </div>
            </div>
          </div>
          <!---->
     
          <a-form-item>
          <a-button class="but-a" type="primary" html-type="submit">登 录</a-button>
          </a-form-item>
          <a-button class="but-a mt50" type="primary" html-type="submit">确认报名</a-button>
         
    <!---->   	
      </div>			
      </a-form>
  
    </a-spin>
    
    </div>
   
  </template>
  
  <script>
  import {addrList} from "@/api/address/index";
  import {majorTree} from '@/api/major/index'
  import {detail} from '@/api/user/index'
  export default {
    name: 'Index',
    data(){
    return{
        isLoading: false,// 正在加载
      addrList:[],
      majorList:[],
      fieldNames:{ label: 'title', value: 'address_id' } ,
      majorNames:{ label: 'name', value: 'major_id' } ,
      
    //   form: this.$form.createForm(this),
    formState:{
      
      nick_name:'',
     
      specialty:'',
      // teacher_name:'',
      // teacher_mobile:'',
      }
    }
    },
    created () {
      // 初始化页面
      this.init()
    },
    methods: {
    back(){this.$router.go(-1)},
    // 初始化页面
      init () {
      detail().then((res)=>{
        let user = res.data.userInfo;
        // this.formState.gender = user.gender=='男'?1:0;
        // this.formState.major_first=user.major_first;
        // this.formState.major_second=user.major_second;
        // this.formState.grade= user.gender=='男'?1:0;
        // this.formState.sign_item=user.sign_item;
        // this.formState.nick_name=user.nick_name;
        // this.formState.gender=user.gender
        // this.formState.birthday=user.birthday;
        // this.formState.IDcard=user.IDcard;
        // this.formState.parent_name=user.parent_name;
        // this.formState.mobile=user.mobile;
        // this.formState.phone=user.phone;
        // this.formState.specialty=user.specialty;
        // this.formState.specialty_year=user.specialty_year;
        // this.formState.teacher_name=user.teacher_name;
        // this.formState.teacher_mobile=user.teacher_mobile;
  
      })
      addrList().then(res=>{
        this.addrList = res.data.addressList;
      })
      
      majorTree().then(res=>{
        this.majorList = res.data.majorList;
        let list = this.majorList;
        list.map(item=>{
           if(item.name==this.formState.major_first){
            this.secondList = item.children;
           }
        })
      })
        
      },
      onFinish(values) {
      console.log(values,this.formState)
      
      }
    }
  }
  </script>
  
  <!-- Add "scoped" attribute to limit CSS to this component only -->
  <style scoped>
  
  </style>
  